<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="/classes/CommonHelper.class.jsp" %>
<%@ include file="/classes/DBHelper.class.jsp" %>
<%@ include file="/classes/GUID.class.jsp"%>
<%@ include file="/classes/MessageUtil.class.jsp"%>
<%
	//String guid = getParameter(request,"guid");
	request.setCharacterEncoding("UTF-8");
	String type_name = getParameter(request,"type_name");
	String order_num = getParameter(request,"order_num");
	
	if( nullOrEmpty(type_name) || nullOrEmpty(order_num)){
		out.print(getAlertMessageAndBack(request,"请检查必填选项是否全部填写！"));
		return;
	}
	
	if(order_num.length()>10){
		out.print("alert(\"排序不能超过10位！\")");
		return;
	}
	
	//检查是否存在
	String guid = getGUID();
	String sqlExists = "select count(*) from APP_ZSPJ_TYPE where type_name = ? ";
	if(queryCount(sqlExists,new Object[]{type_name})>0){
		out.print(getAlertMessageAndBack(request,"类型已存在！"));
		return;
	}
	
	
	String sql = "insert into APP_ZSPJ_TYPE (guid,type_name,order_num) values (?,?,?)";
	int count  = executeUpdate(sql,new Object[]{guid,type_name,order_num});
	if(count>0){
		out.print(getAlertMessage(request,"操作成功！","zspj_type_list.jsp?r="+new Date().getTime(),true));
	}else{
		out.print(getAlertMessage(request,"操作失败！","zspj_type_list.jsp?r="+new Date().getTime(),true));
	}
	
%>